from rest_framework import status
from django.utils.translation import gettext_lazy as _
from rest_framework.exceptions import APIException


class ApiTimeOut(APIException):
    """第三方接口请求超时"""

    status_code = status.HTTP_408_REQUEST_TIMEOUT
    default_detail = _('请求超时，请稍后再试')
    default_code = 'api_timeout'


class ApiServerError(APIException):
    """第三方接口请求错误"""

    status_code = status.HTTP_503_SERVICE_UNAVAILABLE
    default_detail = _('数据获取错误，请检查后重试')
    default_code = 'api_server_error'


class ApiStatusError(APIException):
    """第三方接口成功处理，但返回错误状态"""

    status_code = status.HTTP_503_SERVICE_UNAVAILABLE
    default_detail = _('数据获取错误，请检查后重试')
    default_code = 'api_status_error'


class ApiParamsError(APIException):
    """第三方接口请求错误"""

    status_code = status.HTTP_503_SERVICE_UNAVAILABLE
    default_detail = _('数据获取错误，请检查参数后重试')
    default_code = 'api_params_error'


class EmailSendError(Exception):
    pass


class MaxMultipleDevicesError(Exception):
    pass
